package com.distributed.util;

import java.util.List;

import org.apache.commons.lang.math.RandomUtils;

import com.distributed.common.Address;

public class HashUtils {
	public static Address consistentHash(String code) {
		return null;
	}
	
	public static Address ModHash(List<Address> list, String code) {
		if(list == null || list.size() == 0) {
			return null;
		}
		int hashcode = code.hashCode();
		return list.get(hashcode % list.size());
	}
	
	public static int ModHash(int len, String code) {
		return code.hashCode() % len;
	}
	
	public static Address HashRandom(List<Address> list) {
		if(list == null || list.size() == 0) {
			return null;
		}
		return list.get(RandomUtils.nextInt() % list.size());
	}
}
